<%@ page import="schoolsource.sql.SchoolDBSQL" %>
<%@ page import="schoolsource.gui.FormFields" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="schoolsource.model.*" %>
<%@ page import="schoolsource.security.SecurityToken" %>
<% 
   String message = (String) request.getAttribute("message"); 
   request.setAttribute("message", null); 
   if (message == null) message = ""; 
   String schoolName = (String) request.getAttribute(FormFields.SCHOOLNAME);
   String loginType = (String) request.getAttribute(FormFields.USRTYPE); 
   
   SchoolContainer sc = SchoolContainer.getSchoolContainer(schoolName);
   String schoolLogo = sc.getSchoolLogo().toString();
   String schoolLogoWidth = sc.getSchoolLogoWidth().toString();
   String schoolFullName = sc.getSchoolName().toString();
   
%>

<HTML>
  <HEAD>
      <SCRIPT LANGUAGE="JavaScript">
        function Logon_onload() {
            initializeMainFrame(top.frames.mainframe);
            top.frames.mainframe.document.loginform.<%= FormFields.STUDENTID %>.focus();
        }

        function initializeMainFrame(w) {
            var d = w.document;
            d.write("    <HTML><HEAD></HEAD>\n");
            d.write("    <BODY>\n");
            d.write("    <FORM NAME=\"loginform\" METHOD=\"POST\">\n");
            <%
                Enumeration attrList = request.getParameterNames();
                String attrName;
                while (attrList.hasMoreElements()) {
                    attrName = (String) attrList.nextElement();
                    if (!FormFields.TOKEN.equals(attrName) &&
                        !FormFields.STUDENTID.equals(attrName) &&
                        !SchoolDBSQL.USRPASSWORD.equals(attrName) &&
                        !FormFields.PARENTID.equals(attrName) &&
                        !"submitlogin".equals(attrName)) {
                        out.println("d.write(\"    <INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"" + attrName + "\\\" VALUE=\\\"" + request.getAttribute(attrName) + "\\\">\\n\");");
                    }
                }
            %>

            d.write("      <CENTER><DIV style=\"font-family:sans-serif;width:365px;height:200px;filter:shadow(color:gray);\">\n");
            d.write("      <TABLE style=\"border:1px solid black;\" bgcolor=\#cccccc ALIGN=\"CENTER\" WIDTH=\"350\">\n");
            
            d.write("        <TR>");
            d.write("          <TD COLSPAN=\"3\"><CENTER><B><%= schoolFullName %><BR>Student/Parent Login</B></CENTER></TD>");
            d.write("          <TD></TD>");
            d.write("        </TR>");
            
            d.write("        <TR style=\"font-size:12;\">\n");
            d.write("          <TD ROWSPAN=\"3\" ALIGN=\"CENTER\">");
            d.write("            <DIV><IMG src=\"../pics/<%= schoolLogo %>\" width='85%'; style=\"border:0;white-space:nowrap;\"></DIV>");
            d.write("          </TD>");
            d.write("          <TD ALIGN=\"RIGHT\">Student ID: </TD>\n");
            d.write("          <TD ALIGN=\"LEFT\" COLSPAN=\"2\"><INPUT NAME=\"<%= FormFields.STUDENTID %>\" TYPE=\"TEXT\" SIZE=\"20\"></TD>\n");
            d.write("        </TR>\n");
            
            d.write("        <TR style=\"font-size:12;\">\n");
            d.write("          <TD ALIGN=\"RIGHT\">Password: </TD>\n");
            d.write("          <TD ALIGN=\"LEFT\" COLSPAN=\"2\"><INPUT NAME=\"<%= SchoolDBSQL.USRPASSWORD %>\" TYPE=\"PASSWORD\" SIZE=\"20\"></TD>\n");
            d.write("        </TR>\n");
            
            d.write("        <TR style=\"font-size:12;\">\n");
            d.write("          <TD WIDTH=\"80\" ALIGN=\"RIGHT\">Parent ID: <br>(If applicable)</TD>\n");
            d.write("          <TD ALIGN=\"LEFT\"><INPUT NAME=\"<%= FormFields.PARENTID %>\" TYPE=\"TEXT\" SIZE=\"20\">&nbsp;&nbsp;</TD>\n");
            d.write("        </TR>\n");
            
            d.write("        <TR style=\"font-size:12;\">\n");
            d.write("          <TD COLSPAN=\"3\" ALIGN=\"CENTER\"><B><%= message %></B></TD>\n");
            d.write("        </TR>\n");
            
            d.write("        <TR style=\"font-size:12;\">\n");
            d.write("          <TD COLSPAN=\"4\"ALIGN=\"CENTER\"><INPUT NAME=\"submitlogin\" TYPE=\"SUBMIT\" VALUE=\"Login\"></TD>\n");
            d.write("        </TR>\n");
            
            d.write("      </TABLE></DIV></CENTER>\n");
            d.write("    </FORM>\n");
            d.write("    </BODY></HTML>\n");
            d.close();
      }
      </SCRIPT>
    <TITLE>Student/Parent Login</TITLE>

  </HEAD>
  <BODY onload=Logon_onload()>
  </BODY>
</HTML>
